{$layout}

	{$template "node_menu"}

	<h3>节点详情</h3>
	<table class="ui table definition selectable">
		<tr>
			<td class="title">节点名称</td>
			<td>{{node.name}}</td>
		</tr>
		<tr>
			<td>状态</td>
			<td><label-on :v-is-on="node.isOn"></label-on></td>
		</tr>
		<tr>
			<td>IP地址</td>
			<td>
				<div v-if="node.ipAddresses.length > 0">
					<div>
						<div v-for="(address, index) in node.ipAddresses" class="ui label tiny basic">
                            <span v-if="address.ip.indexOf(':') > -1" class="grey">[IPv6]</span> {{address.ip}}
							<span class="small grey" v-if="address.name.length > 0">（{{address.name}}<span v-if="!address.canAccess">，不可访问</span>）</span>
							<span class="small grey" v-if="address.name.length == 0 && !address.canAccess">（不可访问）</span>
						</div>
					</div>
				</div>
				<div v-else>
					<span class="disabled">暂时还没有填写IP地址。</span>
				</div>
			</td>
		</tr>
		<tr v-if="dnsRoutes.length > 0 && dnsRoutes[0].name.length > 0">
			<td>DNS线路</td>
			<td>
				<span class="ui label tiny basic" v-for="route in dnsRoutes">{{route.name}}</span>
			</td>
		</tr>
        <tr v-if="dnsRecordName.length > 0 && dnsRecordValue.length > 0">
            <td>DNS记录</td>
            <td>
                <table class="ui table celled">
                   <thead class="full-width">
                   <tr>
                       <th>记录名</th>
                       <th>记录类型</th>
                       <th>线路</th>
                       <th>记录值</th>
                   </tr>
                   </thead>
                    <tbody v-for="address in node.ipAddresses" v-if="address.canAccess">
                        <tr v-for="route in dnsRoutes">
                            <td>{{dnsRecordName}}</td>
                            <td>
                                <span v-if="address.ip.indexOf(':') > -1">AAAA</span>
                                <span v-else>A</span>
                            </td>
                            <td>
                                <span v-if="route.name.length > 0">{{route.name}}</span>
                                <span v-else class="disabled">默认</span>
                            </td>
                            <td>{{address.ip}}</td>
                        </tr>
                    </tbody>
                </table>
                <p class="comment">通过设置A记录可以将集群上的服务请求转发到不同线路的节点上。</p>
            </td>
        </tr>
        <tr>
            <td>所属区域</td>
            <td>
                <span v-if="node.region != null" class="ui label small basic">{{node.region.name}}</span>
                <span v-else class="disabled">没有设置区域。</span>
            </td>
        </tr>
		<tr>
			<td>所属分组</td>
			<td>
				<span v-if="node.group != null" class="ui label small basic">{{node.group.name}}</span>
				<span v-else class="disabled">没有设置分组。</span>
			</td>
		</tr>
		<tr>
			<td colspan="2"><more-options-indicator>更多选项</more-options-indicator></td>
		</tr>
		<tbody v-show="moreOptionsVisible">
			<tr>
				<td>SSH主机地址</td>
				<td>
					<div v-if="node.login != null && node.login.params != null && node.login.params.host != null">
						<span v-if="node.login.params.host.length > 0">{{node.login.params.host}}</span>
						<span v-else class="disabled">尚未设置</span>
					</div>
					<div v-else class="disabled">
						尚未设置
					</div>
				</td>
			</tr>
			<tr>
				<td>SSH主机端口</td>
				<td>
					<div v-if="node.login != null && node.login.params != null && node.login.params.host != null">
						<span v-if="node.login.params.port > 0">{{node.login.params.port}}</span>
						<span v-else class="disabled">尚未设置</span>
					</div>
					<span v-else class="disabled">
						尚未设置
					</span>
				</td>
			</tr>
			<tr>
				<td>SSH登录认证</td>
				<td>
					<div v-if="node.login != null && node.login.grant != null && node.login.grant.id > 0">
						<a :href="'/clusters/grants/grant?grantId=' + node.login.grant.id">{{node.login.grant.name}}<span class="small">（{{node.login.grant.methodName}}）</span></a>
					</div>
					<span v-else class="disabled">
						尚未设置
					</span>
				</td>
			</tr>
			<tr>
				<td>CPU线程数</td>
				<td>
					<span v-if="node.maxCPU > 0">{{node.maxCPU}}线程</span>
					<span v-else class="disabled">没有限制。</span>
				</td>
			</tr>
            <tr>
                <td>缓存磁盘容量</td>
                <td>
                    <span v-if="node.maxCacheDiskCapacity == null || node.maxCacheDiskCapacity.count <= 0" class="disabled">没有限制</span>
                   <div v-else>
                       <size-capacity-view :v-value="node.maxCacheDiskCapacity"></size-capacity-view>
                   </div>
                </td>
            </tr>
            <tr>
                <td>缓存内存容量</td>
                <td>
                    <span v-if="node.maxCacheMemoryCapacity == null || node.maxCacheMemoryCapacity.count <= 0" class="disabled">没有限制</span>
                    <div v-else>
                        <size-capacity-view :v-value="node.maxCacheMemoryCapacity"></size-capacity-view>
                    </div>
                </td>
            </tr>
		</tbody>
	</table>
	<div class="ui divider"></div>

	<h3>运行状态</h3>
	<table class="ui table definition selectable">
		<tr>
			<td class="title">是否在运行</td>
			<td>
				<div  v-if="node.status.isActive">
					<span class="green">运行中</span> &nbsp;
					<a href="" @click.prevent="stopNode()" v-if="!isStopping"><span>[通过SSH停止]</span></a>
					<span v-if="isStopping">[停止中...]</span>
				</div>
				<div v-else>
					<span class="red">已断开</span> &nbsp;
					<a href="" @click.prevent="startNode()" v-if="node.isInstalled && !isStarting"><span>[通过SSH启动]</span></a>
					<span v-if="node.isInstalled && isStarting">[启动中...]</span>
					<a v-if="!node.isInstalled" :href="'/clusters/cluster/node/install?clusterId=' + clusterId + '&nodeId=' + node.id" ><span>去安装&gt;</span></a>
				</div>
			</td>
		</tr>
		<tbody v-show="node.status.isActive">
			<tr>
				<td>CPU用量</td>
				<td>{{node.status.cpuUsageText}} &nbsp; <span v-if="node.status.cpuPhysicalCount > 0" class="small grey">（{{node.status.cpuPhysicalCount}}核心/{{node.status.cpuLogicalCount}}线程）</span></td>
			</tr>
			<tr>
				<td>内存用量</td>
				<td>{{node.status.memUsageText}}</td>
			</tr>
			<tr>
				<td>连接数</td>
				<td>{{node.status.connectionCount}}</td>
			</tr>
            <tr>
                <td>负载</td>
                <td>{{node.status.load1m}} &nbsp; {{node.status.load5m}} &nbsp; {{node.status.load15m}} &nbsp; <tip-icon content="三个数字分别代表1分钟、5分钟、15分钟平均负载"></tip-icon></td>
            </tr>
            <tr>
                <td>缓存用量</td>
                <td>
                    磁盘：{{node.status.cacheTotalDiskSize}}  &nbsp; 内存：{{node.status.cacheTotalMemorySize}}
                </td>
            </tr>
            <tr>
                <td>版本</td>
                <td>v{{node.status.buildVersion}}
                    &nbsp; <a :href="'/clusters/cluster/upgradeRemote?clusterId=' + clusterId" v-if="shouldUpgrade"><span class="red">发现新版本v{{newVersion}} &raquo;</span></a>
                </td>
            </tr>
		</tbody>
	</table>
	<p class="comment" v-if="node.status.isActive">每隔30秒钟更新一次运行状态。</p>

	<div class="ui divider"></div>
	<h3>安装信息</h3>
	<table class="ui table definition selectable">
		<tr>
			<td>节点ID<em>（id）</em></td>
			<td>{{node.uniqueId}}</td>
		</tr>
		<tr>
			<td>密钥<em>（secret）</em></td>
			<td>{{node.secret}}</td>
		</tr>
		<tr>
			<td class="title">安装目录</td>
			<td>
				<div v-if="node.installDir.length == 0">使用集群设置<span v-if="node.cluster != null && node.cluster.installDir.length > 0">（{{node.cluster.installDir}}）</span></div>
				<span v-else>{{node.installDir}}</span>
			</td>
		</tr>
		<tr>
			<td>是否已安装</td>
			<td>
				<span v-if="node.isInstalled" class="green">已安装</span>
				<a v-else :href="'/clusters/cluster/installNode?clusterId=' + clusterId + '&nodeId=' + nodeId" class="underline" title="点击进入安装界面"><span class="red">未安装</span></a>
			</td>
		</tr>
	</table>